package com.weijianhuawen.wjblog.web.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.http.client.SimpleClientHttpRequestFactory;
import org.springframework.web.client.RestTemplate;

/**
 * @version: java version 8
 * @Author: weijianhuawen
 * @description: RestTemplate 配置类
 * @date: 2024-12-08 15:31
 */

@Configuration
public class RestTemplateConfig {
    @Bean
    public RestTemplate restTemplate() {
        SimpleClientHttpRequestFactory factory  = new SimpleClientHttpRequestFactory();
        // 设置连接超时时间，设置最大超时时间为5s
        factory.setConnectTimeout(5000);
        // 设置读取时间5s
        factory.setReadTimeout(5000);
        return new RestTemplate(factory);
    }

}
